import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86186
 * Date: 2023-10-09
 * Time: 22:35
 */
public class Test {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int n = in.nextInt();
        String[] str = new String[n];
        for (int i = 0; i < n; i++) {
            str[i] = in.next();
        }
        boolean flg1 = false, flg2 = false;
        for (int i = 0; i < n - 1; i++) {
            if (str[i].length() > str[i + 1].length()) flg1 = true;
            if (str[i].compareTo(str[i + 1]) > 0) flg2 = true;
        }

        if (flg1 && flg2) {
            System.out.println("none");
        }else if(!flg1 && !flg2) {
            System.out.println("both");
        }else if(!flg1 && flg2) {
            System.out.println("lengths");
        }else {
            System.out.println("lexicographically");
        }
    }

    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        long a = in.nextInt();
        long b = in.nextInt();
        long t1 = a, t2 = b;
        while (b != 0) {
            long tmp = a % b;
            a = b;
            b = tmp;
        }
        System.out.println(t1 * t2 / a);
    }
}
